<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.TSystemUser"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String type = request.getParameter("type");
String roleRroupId = request.getParameter("roleRroupId");
//String treepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/RQOAtree/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>粮油集团办公自动化协作平台</title>
<link href="<%=basePath %>style/txlz7.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>ajaxFramework/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-all.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/init.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ux/ux-all.js"></script>	
<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.form.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/global/pageControl.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/system/departmenttree.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/system/dutytree.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/system/posttree.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/system/rolesgrouptree.js"></script>
<script type="text/javascript" src="<%=basePath %>js/common/system/updateroleslist.js"></script>

<script type="text/javascript">
    var type = '<%out.print(type); %>';
    var roleRroupId = '<%out.print(roleRroupId); %>';
	var i =0
	$(function(){
		$.ajaxSetup({
		  async: false
		  }); 
		$("input[name='loginname']").change(issameloginname);  
		$(".s09 >a").attr("href","javascript:formsubmit()");
		$(".s10 >a").attr("href","javascript:back()");
		$("#index_title a").get(0).href="javascript:change()";
		$("#index_title a").get(1).href="javascript:change()";
		initdepartmenttree();
		initdutytree();
		initposttree();
		initposttree();
		initrolesgrouptree();
		initupdateroleslist();
	});
	function change(){
		$("#ischang").attr('value',1);
		$("#index_title ul li:eq(0)").toggleClass("over");
		$("#index_title ul li:eq(1)").toggleClass("over");
		$(".gwlz01").toggle();
		$(".gwlz01+div").toggle();
		if(i ==0)
		{
			rolessort.load({
			callback:function(){
					rolessort.each(function(record){
					if(record.get('chk') == true)
					{
						rolessm.selectRecords([record],true);
					}
				});
			} 
		});
			i = 1;
		}
	
	}
	function issameloginname(){
		
		var loginname = $.trim($("input[name='loginname']").attr('value'));
		var start = true;
		if($("input[name='oldloginname']").attr('value') == loginname )
		{
			return true;
		}
		$.get("<%=basePath%>tjsinfo/tjsoa/system/issameloginname.do",{loginname:loginname},function(data){
			if(data == 'false'){
				start = false;
				Ext.MessageBox.alert('提示信息', '帐号名称不能重复',function(){
					$("input[name='loginname']").select();	
				});
						
			}
		});	
		return start;
	}
	
	function issameusername(){
		var username = $.trim($("input[name='username']").attr('value'));
		var start = true;
		if($("input[name='oldusername']").attr('value') == username )
		{
			return true;
		}
		$.get("<%=basePath%>tjsinfo/tjsoa/system/issameusername.do",{username:username},function(data){
			if(data == 'false'){
				start = false;
				Ext.MessageBox.alert('提示信息', '用户名不能重复',function(){
					$("input[name='username']").select();	
				});
						
			}
		});	
		return start;
	}
	
	
	function back(){
	if(type==1){
	     window.location.href="<%=basePath%>system/roleGroup/userchecklist.jsp?fanhui=true&id="+roleRroupId;	
	}else{
	     window.location.href="<%=basePath%>system/user/userlist.jsp?fanhui=true";	
	}
	}
	function formsubmit(){
		selectrolesrows();
		if(isnull("input[name='orderNo']","序号不能为空")
		&&mustisnumber("input[name='orderNo']","序号必须为正整数") 			
		&&isnull("input[name='loginname']","帐号名称不能为空")
		&&isnull("input[name='username']","姓名不能为空")
		&&isnull('#departmentname',"部门不能为空")
		&&isnull('#dutyname',"职位不能为空")
		&&issameloginname()
		&&issameusername())
		{
			if($.trim($("input[name='email']").attr("value")) != '')
				{
					
					if(validatoremail("input[name='email']","电子邮箱格式不符"))
					{
						var loginname = $.trim($("input[name='loginname']").attr('value'));
						$("input[name='loginname']").attr('value',loginname);
						msg();
						$("form[name='form1']").submit();	
					}
				}
				else
				{
					var loginname = $.trim($("input[name='loginname']").attr('value'));
					$("input[name='loginname']").attr('value',loginname);
					msg();
					$("form[name='form1']").submit();
				}
			
		}	
	}	
	
	function erjigongsiwindow(){
		var win = userinforadiotree();
		win.show();
		win.on("winsubmint",function(data){
			$("#erjigongsiname").val(data.usernametext);
			$("#erjigongsiid").val(data.userid);
			$("#userdatabaseId").val(data.userdatabaseId);
			win.hide();
		});
	}
</script>
</head>
<style>
#right .contabwd_02{
width:99%; margin-top:6px; border:1px #9DB0BC solid; background:#fff; height:99%; float:left;}
</style>
  
  <body>
  	<%
  	TSystemUser systemUser  = (TSystemUser)request.getAttribute("systemUser");
  	String systemUserDepartmentname = (String)request.getAttribute("systemUserDepartmentname");
  	String systemUserDutyname = (String)request.getAttribute("systemUserDutyname");
  	String systemUserPostname= (String)request.getAttribute("systemUserPostname");
  	String systemUserRoleGroupname= (String)request.getAttribute("systemUserRoleGroupname");
  	String systemUserDepartmentid = (String)request.getAttribute("systemUserDepartmentid");
  	String systemUserDutyid = (String)request.getAttribute("systemUserDutyid");
  	String systemUserPostid= (String)request.getAttribute("systemUserPostid");
  	String systemUserRoleGroupid=(String)request.getAttribute("systemUserRoleGroupid");
  
  	%>
  <form action="<%=basePath %>tjsinfo/tjsoa/system/alterUser.do?type=<%=type %>&id=<%=roleRroupId %>" method="post" name="form1">
	    <div style="height:98%">
	<div id="right">
	      <div class="p_01">
			    <ul>
	                <li class="s09"><a href="#">提交</a></li>
	                <li class="s10"><a href="#">返回</a></li>
	            </ul>
		  </div>
		  
	      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="95%">
	          <tr>
	            <td width="100%" valign="top" height="100%">
	               <div class="contabwd_02">
	                     <div id="index_title">
	                        <ul>
	                            <li class="over" ><a href="#"><span>用户信息</span></a></li>
	                            <li ><a href="#"><span>权限</span></a></li>
	                        </ul>
	                     </div>
	                     <div class="gwlz01" id="gwlz01">
	                     <table width="399" border="0" cellspacing="0" cellpadding="0" align="center">
	                     	  <tr>
	                            <td><img src="<%=basePath %>images/lwxx_15.gif" /></td>
	                          </tr>
	                          <tr>
	                    		<td><div class="lwxx">
	                            	<table width="361" height="271" border="0" align="center" cellpadding="0" cellspacing="0" class="ttaa">
	                                	  <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;序号</td>
	                                        <td width="258" align="right"><input name="orderNo" type="text" maxlength="6" value="<%=systemUser.getOrderNo() %>" size="44" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23">&nbsp;</td>
	                                      </tr>
	                                	  <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;帐号名称</td>
	                                        <td width="258" align="right"><input name="loginname"  type="text" maxlength="20" value="<%=systemUser.getLoginName() %>" size="44" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23">&nbsp;</td>
	                                      </tr>
	                                    
	                                      <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;姓名</td>
	                                        <td width="258" align="right"><input name="username" type="text" maxlength="50" value="<%=systemUser.getUserName() %>" size="44" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px" onchange="issameusername()"/></td>
	                                        <td width="23">&nbsp;</td>
	                                      </tr>
	                                       <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;电子邮箱</td>
	                                        <td width="258" align="right"><input name="email" type="text" maxlength="40" value="<%=systemUser.getEmail() %>" size="44" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23">&nbsp;</td>
	                                      </tr>
	                                      <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;部门</td>
	                                        <td width="258" align="right"><input id="departmentname" name="textfield2" type="text" value="<%=systemUserDepartmentname %>" size="44"  readonly="readonly" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23"><a href="javascript:void(0)" onclick="departmentwinshow('departmentid','departmentname')"><img src="<%=basePath %>images/yhglgd.gif" /></a></td>
	                                      </tr>
	                                      <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;职位</td>
	                                        <td width="258" align="right"><input id='dutyname' name="textfield2" type="text"  value="<%=systemUserDutyname %>" size="44"  readonly="readonly" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23"><a href="javascript:void(0)" onclick="dutywinshow('dutyid','dutyname')"><img src="<%=basePath %>images/yhglgd.gif" /></a></td>
	                                      </tr>
	                                      <tr>
	                                        <td width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;岗位</td>
	                                        <td width="258" align="right"><input id="postname" name="textfield2" type="text" value="<%=systemUserPostname %>" size="44" readonly="readonly" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></td>
	                                        <td width="23"><a href="javascript:void(0)" onclick="postwinshow('postid','postname')"><img src="<%=basePath %>images/yhglgd.gif" /></a></td>
	                                      </tr>
	                                      <tr>
	                                        <th width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;权限组</th>
	                                        <th width="258" align="right"><input id="rolesgroupname" name="textfield2"  type="text" value="<%=systemUserRoleGroupname %>" size="44" readonly="readonly" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></th>
	                                        <th width="23"><a href="javascript:void(0)" onclick="rolesgroupwinshow('rolesgroupid','rolesgroupname')"><img src="<%=basePath %>images/yhglgd.gif" /></a></th>
	                                      </tr>
	                                       <%--
	                                       <tr>
	                                        <th width="80" align="right"><img src="<%=basePath %>images/dfdf_03.gif" />&nbsp;替代账户</th>
	                                        <th width="258" align="right"><input id="erjigongsiname" name="textfield2" type="text" size="44" readonly="readonly" value="<%=systemUser.getSubUserName() %>" style="border:1px #C0C0C0 solid;background:#F4F4F4; height:19px"/></th>
	                                        <th width="23"><a href="javascript:void(0)" onclick="erjigongsiwindow()"><img src="<%=basePath %>images/yhglgd.gif" /></a></th>
	                                      </tr>
	                                    
	                                      --%>
	                                      </table>
	                                      </div>
	                               </td>
	                          </tr>
	                          <tr>
	                            <td><img src="<%=basePath %>images/lwxx_03.gif" /></td>
	                          </tr>
	                        </table>
	                      </div>
	                      <div style="display:none">
	                      	<div id="rolesdiv" style="width: 840px" ></div>	             
	                      </div>
	     				</div>
	            </td>
	          </tr>
	      </table>
	
	</div>
	</div>
	<input type="hidden" id="basePath" value="<%=basePath%>"/>
	<input type="hidden" id="userid" name="userid" value="<%=systemUser.getUserId()%>"/>
	<input type="hidden" id="departmentid" name="departmentid" value="<%=systemUserDepartmentid %>"/>
	<input type="hidden" id="dutyid" name="dutyid" value="<%=systemUserDutyid %>"/>
	<input type="hidden" id="postid" name="postid" value="<%=systemUserPostid %>"/>
	<input type="hidden" id="rolesgroupid" name="rolesgroupid" value="<%=systemUserRoleGroupid %>"/>
	<input type="hidden" id="rolesid" name="rolesid"/>
	<input type="hidden" id="oldloginname" name="oldloginname" value="<%=systemUser.getLoginName() %>"/>
	<input type="hidden" id="oldusername" name="oldusername" value="<%=systemUser.getUserName() %>"/>
	<input type="hidden" id="ischang" name="ischang" value="0"/>
	<input type="hidden" id="erjigongsiid" name="erjigongsiid" value="<%=systemUser.getSubUserId() %>"/>
	<input type="hidden" id="userdatabaseId" name="userdatabaseId" value="<%=systemUser.getDataBaseId() %>"/>
	</form>
	<script type="text/javascript">
		document.getElementById('gwlz01').style.height = document.body.clientHeight-140;
	</script>
  </body>
</html>
